package com.baicaoyuan.web.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@RequiredArgsConstructor
@Getter
public enum ClientTypeEnum {

    /**
     * 手机端
     */
    WAP("1"),

    /**
     * PC端
     */
    WEB("2"),

    /**
     * 管理端
     */
    ADMIN("3");


    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param client
     * @return
     */
    public static ClientTypeEnum acquire(final String client) {
        Optional<ClientTypeEnum> belongEnum = Arrays.stream(ClientTypeEnum.values())
                .filter(v -> Objects.equals(v.getStatus(), client))
                .findFirst();
        return belongEnum.orElse(ClientTypeEnum.WAP);
    }

}
